package com.zhou.common.mybatis.template.shiro.filter;


import org.springframework.web.filter.OncePerRequestFilter;
import org.springframework.web.util.WebUtils;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class RewriteServletReuqestUriFilter extends OncePerRequestFilter {


    @Override
    protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
        String requestURI = request.getRequestURI();
        if (requestURI.startsWith("/webPortal")){
            request.setAttribute(WebUtils.INCLUDE_REQUEST_URI_ATTRIBUTE,requestURI.replace("/webPortal",""));
        }
        filterChain.doFilter(request,response);

    }
}
